package com.wpw.java7demo;

import java.util.ArrayList;
import java.util.List;

import org.junit.Test;

public class FanXingTest {

	@Test
	public void test1() {
		List<Parent> list = new ArrayList<>();
		add(list);
		GrandParent grandParent = get(list);
		System.out.println(grandParent.getClass());
	}
	
	private void add(List<? super Child> list) {
		list.add(new Child());
	}
	
	private GrandParent get(List<? extends GrandParent> list) {
		return list.get(0);
	}
	
	@SuppressWarnings("unused")
	@Test
	public void test2() {
		Parent p = new Child();
		//List<Parent> list = new ArrayList<Child>();编译不通过
		List<Child> list2 = new ArrayList<>();
		//add2(list); //编译不通过
		//GrandParent grandParent = get2(list); //编译不通过
	}
	
	@SuppressWarnings("unused")
	private void add2(List<Parent> list) {
		list.add(new Child());
	}
	
	@SuppressWarnings("unused")
	private GrandParent get2(List<GrandParent> list) {
		return list.get(0);
	}
	
	@Test
	public void test3() {
		int i = 1;
		if (i < 5) {
			System.out.println("i<5");
		} else if (i < 4) {
			System.out.println("i<4");
		} else if(i>0) {
			System.out.println("i>0");
		} else {
			System.out.println("ddd");
		}
	}
	
}
